#include <stdio.h>
#include <iostream>
#include <sstream>
#include <time.h>
#include <chrono>
using namespace std;
int main()
{
    // time_t tim;
    // time(&tim);
    // // tim = time(NULL);
    // char get_req_time[1024];
    // ctime_r(&tim, get_req_time);
    // // string get_req_time = ctime(&tim);
    // printf("%s", ctime(&tim));
    // printf("%s", get_req_time);
    // cout << get_req_time << endl;
    // unsigned int seconds_since_1900 = tim;
    // // unsigned int fraction = ntohl(ntp_response.transmit_timestamp[1]);
    // time_t timestamp = seconds_since_1900;
    // printf("NTP server time: %s", ctime(&timestamp));
    time_t tim;
    string out = "";
    long timestamp = time(&tim);//orgin_time
    ostringstream oss;
    oss<< timestamp;
    string timestamp_str = oss.str();
    out += timestamp_str;
    cout << out << endl;


    time_t time_stamp = 1699966694; // 时间戳，单位为秒
    struct tm *timeinfo;
    char buffer[80];

    timeinfo = localtime(&time_stamp); // 将时间戳转换为本地时间
    strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeinfo); // 将时间格式化为指定格式

    printf("时间戳 %ld 对应的时间为: %s\n", time_stamp, buffer);
    return 0;
}